<template>
    <button @click="clipboardToDoc" />
<div v-if="isGetDoc" id="Example">
    <Markdown :source="doc" />
</div>

</template>


<style scoped>
#Example{
    text-align: left !important;
    font-family: "Times New Roman", SimSun;
}

</style>

<script>
import Markdown from 'vue3-markdown-it'

async function blobToString (blob) {
    return new Promise((resolve, reject) => {
                const reader = new FileReader();
                reader.onerror = reject;
                reader.onload = () => { resolve(reader.result) };
                reader.readAsDataURL(blob);
            })
        }

export default {
    components: {
        Markdown,

    },
    data(){ return {
        isGetDoc : true,
        doc : '',
        docBlob : '',
    } },
    methods:{
        async clipboardToDoc() {
            this.doc = await navigator.clipboard.readText();
            this.docBlob = new Blob([this.doc], { type : 'plain/text' });

            //const base64String = await blobToString(blob);
            //let a = atob(base64String)
            //console.log(this.docBlob)

            /*
            console.log(blob)
            var reader = new FileReader();
            reader.onload = function() {
                alert(reader.result);
            }
            reader.readAsText(blob);
            */
        },




    }
}
</script>